const app = getApp()
Page({
  data: {
    listNotice: []
  },
  onLoad: function() {
    const that = this
    wx.cloud.database({
      env: 'gtss-2b1812'
    }).collection('Notice').where({
      dept: app.globalData.userDept
    }).limit(20).orderBy('time', 'desc').get({
      success(res) {
        that.setData({
          listNotice: that.data.listNotice.concat(res.data)
        })
      }
    })
  },
  onReachBottom: function() {
    const that = this
    wx.cloud.database({
      env: 'gtss-2b1812'
    }).collection('Notice').where({
      dept: app.globalData.userDept
    }).limit(20).skip(that.data.listNotice.length).orderBy('time', 'desc').get({
      success(res) {
        that.setData({
          listNotice: that.data.listNotice.concat(res.data)
        })
      }
    })
  }
})